﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Super.Common.DB;
using Super.DomainService;
using Super.Entities;
using Super.Infrastructure;

namespace ChDic.Controllers
{
    public class testController : Controller
    {
        //
        // GET: /test/

        public ActionResult Index() 
        {
            bool r = false;
            var dt = AccessHelper.ReadAllData("xhzd_surnfu", "D:\\Project\\JCSoft\\Super\\dic.mdb", ref r);
            var adp = new DbContextAdapter(false);
            var dicService = new BaseService<ChineseDictionary>(adp);

            foreach (DataRow item in dt.Rows)
            {
                var model = new ChineseDictionary();
                model.ZI = item["zi"].ToString();
                model.PY =item["py"].ToString();
                model.WuBi = item["wubi"].ToString();
                model.BuShou = item["bushou"].ToString();
                model.BiHua = item["bihua"].ToString().ToInt(0);
                model.DuYin = item["pinyin"].ToString();
                model.JieShi = item["jijie"].ToString();
                model.XiangJie = item["xiangjie"].ToString();
                dicService.Repository.InsertOrUpdate(model);

            }

            adp.SaveChanges();
            return View();
        }

    }
}
